package com.codedancer.campus.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.codedancer.campus.common.typehandler.CodeEnumTypeHandler;
import com.codedancer.campus.enums.HeadlineNewsType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName(value = "headline_news", autoResultMap = true)
@Table(name = "headline_news", comment = "头条新闻")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HeadlineNews {

    @TableId
    @TableField("uuid")
    @Column(name = "uuid", type = MySqlTypeConstant.VARCHAR, length = 36, isKey = true, isNull = false, comment = "uuid")
    private String uuid;

    @TableField("title")
    @Column(name = "title", type = MySqlTypeConstant.TEXT, isNull = false, comment = "新闻标题")
    private String title;

    @TableField("description")
    @Column(name = "description", type = MySqlTypeConstant.TEXT, isNull = false, comment = "新闻描述")
    private String description;

    @TableField("cover_image")
    @Column(name = "cover_image", type = MySqlTypeConstant.TEXT, isNull = true, comment = "封面图片")
    private String coverImage;

    @TableField("source")
    @Column(name = "source", type = MySqlTypeConstant.VARCHAR, length = 64, isNull = false, comment = "新闻来源")
    private String source;

    @TableField("url")
    @Column(name = "url", type = MySqlTypeConstant.VARCHAR, length = 512, isNull = false, comment = "新闻地址")
    private String url;

    @TableField("publish_date")
    @Column(name = "publish_date", type = MySqlTypeConstant.DATETIME, isNull = false, comment = "发布日期")
    private Date publishDate;

    @Column(name = "create_time", type = MySqlTypeConstant.DATETIME, isNull = false, comment = "创建时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Column(name = "update_time", type = MySqlTypeConstant.DATETIME, isNull = false, comment = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @TableField(value = "type", typeHandler = CodeEnumTypeHandler.class)
    @Column(name = "type", type = MySqlTypeConstant.TINYINT, length = 1, isNull = false, comment = "新闻类型 1表示本地新闻 2表示其他新闻", defaultValue = "2")
    private HeadlineNewsType type;

    @TableField("location")
    @Column(name = "location", type = MySqlTypeConstant.VARCHAR, length = 16, isNull = true, comment = "头条新闻所属地")
    private String location;
}
